﻿@{
    Layout = null;
    Model.Intelligence_AutoStock AutoStockData = ViewBag.AutoStock;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>管理工具</title>
    <!--SEO优化部分 & 全局样式部分-->
    @Html.Partial("_Title")
    <script src="~/Theme/layui/layui.js"></script>
    <script src="~/Theme/layer/layer.js"></script>
    <link href="~/Theme/css/IntelligenceManageCSS.css" rel="stylesheet" />
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <!--头部-->
        @Html.Partial("_Top")
        <!--左侧-->
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item"><a href="/IntelligenceManage/AutoResend">自动重发商品</a></li>
                    <li class="layui-nav-item"><a href="/IntelligenceManage/AutoAppraise">自动评价订单</a></li>
                    <li class="layui-nav-item"><a href="/IntelligenceManage/AutoWindow">自动橱窗位</a></li>
                    <li class="layui-nav-item layui-this"><a href="/IntelligenceManage/AutoStock">自动补库存</a></li> 
                </ul>
            </div>
        </div>

        <div class="layui-body" style="">
            <fieldset class="layui-elem-field layui-field-title mt20">
                <legend>自动补库存</legend>
            </fieldset>
            <div class="layui-row">
                <div class="layui-form" action="">

                    <div class="layui-form-item">
                        <label class="layui-form-label">补库存开关</label>
                       
                        @if (AutoStockData.IsAutoStock)
                        {
                            <input type="checkbox" name="open" checked="" lay-skin="switch" lay-text="开启|关闭">
                        }
                        else
                        {
                            <input type="checkbox" name="open" lay-skin="switch" lay-text="开启|关闭">
                        }
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">补库存记录</label>
                        <div class="layui-input-block">
                            <span>今天共补：<span class="layui-badge">19</span>个商品的库存</span>，
                            <span>共补：<span class="layui-badge">683</span>个商品的库存</span>          
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">补库存商品范围</label>
                        <div class="layui-input-block">
                           
                            @if (AutoStockData.IsAllProduct)
                            {
                                <input type="radio" name="IsAllProduct" value="true" title="全店" checked="checked">
                                <input type="radio" name="IsAllProduct" value="false" title="按类目">
                            }
                            else
                            {
                                <input type="radio" name="IsAllProduct" value="true" title="全店">
                                <input type="radio" name="IsAllProduct" value="false" title="按类目" checked="checked">
                            }
                        </div>
                       
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">禁止补库存商品</label>
                        <div class="layui-input-block">
                            <span><span>7</span>个</span>
                            <a href="#" class="font-blue">设置</a>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">设置规则</label>
                        <div class="layui-input-block">
                            <span>商品的可售数量不足 </span>
                            <input class="w50 pl5 pr5" type="text" id="DuanqueNumberId" value="@AutoStockData.DuanqueNumber" onkeyup="this.value=this.value.replace(/\D/g,'')">
                            <span>件，自动增加</span>
                            <input class="w50 pl5 pr5" type="text" id="AddNumberId" value="@AutoStockData.AddNumber" onkeyup="this.value=this.value.replace(/\D/g,'')">
                            <span>件</span>
                        </div>
                    </div>
                   

                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">功能说明</label>
                        <div class="layui-input-block mt20 border-p1-c1">
                            <ul class="ih30 f12">
                                <li><span class="layui-badge-dot"></span>1.商品可售数量是按产品规格对应的数量来计算，不是按商品总数来计算。</li>
                                <li><span class="layui-badge-dot"></span>2.系统每天早上7点更新，超过7点库存不足的产品，第二天7点系统会自动补上库存。</li>    
                            </ul>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn submitbtn" lay-submit="" lay-filter="demo1">保存设置</button>
                        </div>
                    </div>
                </div>
            </div>

            <input type="hidden" value="@AutoStockData.MemberId" id="MemberId" />
            <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
            <script>


                layui.use(['form', 'layedit', 'laydate'], function () {

                    // 点击保存。
                    $(".submitbtn").click(function () {

                        var MemberId = $("#MemberId").val();
                        var open = $("input[name='open']").prop('checked')
                        var IsAllProduct = $("input[name='IsAllProduct']:checked").val();

                        var DuanqueNumber = $("#DuanqueNumberId").val();
                        var AddNumber = $("#AddNumberId").val();


                        var data = JSON.stringify({ MemberId: MemberId, open: open, IsAllProduct: IsAllProduct, customResend: "必推产品", DuanqueNumber: DuanqueNumber, AddNumber: AddNumber });

                        //提示弹层
                        layer.msg('正在提交保存...', { icon: 16, shade: [0.5, '＃f5f5f5'], scrollbar: false, offset: '300px', time: 50000 });
                        $.ajax({
                            url: "/api/IntelligenceManageAPI/UpdateAutoStock",
                            type: "Post",
                            dataType: "json",
                            data: { data: data },
                            success: function (data) {

                                //关闭弹层提示
                                layer.closeAll();

                                if (data == true) {
                                    layer.msg('保存成功', {
                                        offset: '60px'
                                    });
                                }
                                else {

                                    layer.msg('保存失败', {
                                        offset: '60px'
                                    });

                                }
                            }
                        })

                    })
                });
            </script>
        </div>
        <!--底部-->
        @*@Html.Partial("_Foot")*@
    </div>
</body>
</html>



